var t = require("../../../@babel/runtime/helpers/interopRequireDefault").default, a = require("../../../config/CT_share_index/index.js"), e = t(require("../../../behaviors/aucMiniAuth")), i = t(require("../../../api/api_CTShare")), c = require("../../../utils/regs"), s = t(require("../../../utils/Tips")), o = t(require("../../../kta/index")), n = (t(require("../../../api/wxRequest.js")), 
getApp());

n.eventBus;

Component({
    behaviors: [ e.default ],
    properties: {},
    data: {
        CTImageBaseUrl: a.imageBaseUrl.CT_share_index,
        shareId: "",
        account1: "",
        account2: "",
        giftCode: "",
        showSuccessBox: !1,
        actionEndFlag: !1
    },
    attached: function() {
        this.setData({
            actionEndFlag: n.globalData.actionEndFlag
        }), this.api_listGifts();
    },
    methods: {
        showForbiddenToast: function() {
            s.default.toast("活动已过期");
        },
        closeSuccess: function() {
            this.setData({
                showSuccessBox: !1
            }), this.gotoIndex();
        },
        gotoIndex: function() {
            wx.navigateBack({
                delta: 1
            });
        },
        getInputValue1: function(t) {
            var a = t.detail.value;
            this.setData({
                account1: a
            });
        },
        getInputValue2: function(t) {
            var a = t.detail.value;
            this.setData({
                account2: a
            });
        },
        clickExchange: function() {
            this.data.account1 == this.data.account2 && c.qq.test(this.data.account1) ? (o.default.clickStat("e604b77261654cc8901546031dfaec6e", {
                userphone: n.globalData.aucPhone
            }), this.api_exchange()) : s.default.toast("请输入正确的QQ号");
        },
        api_exchange: function() {
            var t = this, a = {
                giftCode: this.data.giftCode,
                account: this.data.account1,
                accountType: "qq"
            };
            i.default.receive(a).then(function(a) {
                console.log("兑换礼品接口返回 res", a);
                var e = a.code, i = (a.result, a.msg);
                "0" === e ? t.setData({
                    showSuccessBox: !0
                }) : s.default.toast(i || "请求失败");
            }).catch(function() {
                s.default.toast("兑换礼品请求失败");
            });
        },
        api_listGifts: function() {
            var t = this;
            i.default.listGifts().then(function(a) {
                console.log("获取礼品编码接口返回 res", a);
                var e = a.code, i = a.result, c = a.msg;
                "0" === e ? t.setData({
                    giftCode: i[0].giftCode
                }) : s.default.toast(c || "请求失败");
            }).catch(function() {
                s.default.toast("获取礼品编码请求失败");
            });
        },
        clickInv: function() {
            o.default.clickStat("f1a6761adeac456f9f4aff717acd593b", {
                userphone: n.globalData.aucPhone
            });
        }
    }
});